package com.gel.shortLink.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gel.shortLink.convention.result.Result;
import com.gel.shortLink.convention.result.Results;
import com.gel.shortLink.dto.req.*;
import com.gel.shortLink.dto.resp.ShortLinkPageRespDTO;
import com.gel.shortLink.service.RecycleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*回收站控制器*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/short-link/project/link/recycle")
public class RecycleController {
    private final RecycleService recycleService;

    /*移至回收站*/
    @PostMapping("/save")
    public Result<Void> save(@RequestBody RecycleBinSaveReqDTO requestParam) {
        recycleService.save(requestParam);
        return Results.success();
    }
    /*分页查询回收站*/
    @GetMapping("/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageRecycleShortLink( RecyclePageReqDTO requestParam){
        IPage<ShortLinkPageRespDTO> result = recycleService.pageShortLink(requestParam);
        return Results.success(result);

    }
    /*恢复短链接*/
    @PostMapping("/recover")
    public Result<Void> recover(@RequestBody RecycleBinRecoverReqDTO requestParam) {
        recycleService.recover(requestParam);
        return Results.success();
    }
    /*移除回收站链接*/
    @DeleteMapping("/remove")
    public Result<Void> remove(@RequestBody RecycleBinRemoveReqDTO requestParam) {
        recycleService.remove(requestParam);
        return Results.success();
    }
}
